<!--# layout("/common/layout.html",{"jsBase":"/js/question/question/"}){ -->

<form class="layui-form layui-form-pane" id="addForm" enctype="multipart/form-data"  lay-filter="editform">
    <input type="hidden" name="questionId" id="questionId">
    <br>
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
            <label class="layui-form-label">问题标题</label>
                <div class="layui-input-inline" style="width:350px">
                    <input type="text" name="title" id="title" autocomplete="off" maxlength="80" class="layui-input" lay-verify="required">
                </div>
            </div>
        </div>
    </div>

    <div class="layui-row">
        <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">问题描述</label>
            <div class="layui-input-block" style="width:512px">
                <textarea name="describe" id="describe" required lay-verify="required" placeholder="请输入" class="layui-textarea" style="height: 200px;"></textarea>
            </div>
        </div>
        </div>
    </div>

    <div class="layui-row">
        <div class="layui-form-item">
        <div class="layui-inline">
        <label class="layui-form-label">是否公开</label>
            <div class="layui-input-inline">
                <input type="radio" name="isOpen" value="1" title="是" checked="" >
                <input type="radio" name="isOpen" value="0" title="否">
            </div>
        </div>
        <div class="layui-inline">
        <label class="layui-form-label">是否推荐</label>
            <div class="layui-input-inline">
                <input type="radio" name="isTop" value="1" title="是" checked="" >
                <input type="radio" name="isTop" value="0" title="否">
            </div>
        </div>
        </div>
    </div>

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">回答数</label>
                <div class="layui-input-block">
                    <input type="text" name="answerCount" id="answerCount" autocomplete="off" maxlength="50" class="layui-input" placeholder="请输入数字" lay-verify="number">
                </div>
            </div>
            <div class="layui-inline">
            <label class="layui-form-label">关注数</label>
				<div class="layui-input-block">
                    <input type="text" name="followCount" id="followCount" autocomplete="off" maxlength="50" class="layui-input" placeholder="请输入数字" lay-verify="number">
				</div>
            </div>
        </div>
    </div>

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">提问者</label>
                <div class="layui-input-inline">
                    <layui:simpleDataSelect name="customerId" value="" data="${customerInfoList}" lay-verify="required"
                                            attrId="customerId" attrName="customerName" layFilter="customerFilter" id="customer_author" laySearch="true" />
                </div>
            </div>
        </div>
    </div>

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <layui:image id="file" tagName="附件" tips="图片说明"/>
            </div>
        </div>
    </div>

    <layui:submitButtons id="addButton" />
</form>
<!--#} -->


<script>
    Common.initImage();
layui.extend({
    loading: '../../../plugins/layui_extends/loading/loading',
}).define([ 'form', 'laydate', 'table','loading','questionApi'], function(exports) {
    var form = layui.form;
    var questionApi = layui.questionApi;
    var index = layui.index;
    var isNew = true;
    <!--# if(!(isEmpty(questionJson))){  -->
    isNew = false;
    <!--# } -->
    var view = {
        init:function(){
            Lib.initGenrealForm($("#addForm"),form);
            this.initSubmit();
        },
        initSubmit:function(){
            $("#addButton").click(function(){
                // $("#addButton").hide();
                // $("#addButton-loading").show();
                // $("#addButton-loading").loading();
                form.on('submit(form)', function(){
                    questionApi.saveForm(isNew,$('#addForm'),function(){
                        parent.window.dataReload();
                        Common.info("保存成功");
                        Lib.closeFrame();
                    });
                });
            });
            $("#addButton-cancel").click(function(){
                Lib.closeFrame();
            });
        }
    }
    view.init();
    <!--# if(!(isEmpty(questionJson))){  -->
    var formJson = ${questionJson};
    form.val("editform",formJson);
    $(".image-preview").each(function() {
        $(this).attr("src",formJson[$(this).attr("id")]);
    });
    <!--# } -->

    form.on('select(customerFilter)', function(data){
        // $("#author").val($("#customer_author").find("option:selected").text());
    });
});
</script>
